package com.ruoyi.ly.controller;


import com.ruoyi.ly.domain.ServeExamineFlow;
import com.ruoyi.ly.domain.dto.PageProjectDTO;
import com.ruoyi.ly.domain.dto.PageServeExamineFlowDTO;
import com.ruoyi.ly.domain.dto.ProjectAddDTO;
import com.ruoyi.ly.domain.dto.ServeFlowPlanAppDTO;
import com.ruoyi.ly.domain.vo.ProjectUpdateVO;
import com.ruoyi.ly.domain.vo.ServeExamineFlowDetailVO;
import com.ruoyi.ly.service.ServeExamineFlowService;
import com.ruoyi.ly.utils.PageResult;
import com.ruoyi.ly.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/ctnm-ly/flow")
@Slf4j
@Api(tags = "巡检记录接口")
public class ServeExamineFlowController {

    @Autowired
    private ServeExamineFlowService serveExamineFlowService;




    //分页查询巡检记录
    @ApiOperation("分页查询巡检记录")
    @GetMapping("/page")
    public Result<PageResult> page(PageServeExamineFlowDTO pageServeExamineFlowDTO) {
        log.info("分页查询：{}", pageServeExamineFlowDTO);
        PageResult pageResult = serveExamineFlowService.pageQuery(pageServeExamineFlowDTO);
        return Result.success(pageResult);
    }

    //查询巡检记录详情
    @ApiOperation("根据巡检记录id查询巡检记录")
    @GetMapping("/selectById/{examineFlowId}")
    public  Result<ServeExamineFlowDetailVO> selectById(@PathVariable Long examineFlowId) {
        log.info("根据巡检记录id查询巡检记录：{}",examineFlowId);
        ServeExamineFlowDetailVO serveExamineFlowDetailVO = serveExamineFlowService.selectById(examineFlowId);
        return Result.success(serveExamineFlowDetailVO);
    }

    //查询巡检记录详情(未巡检时小程序端使用)
    @ApiOperation("查询巡检记录详情(未巡检时小程序端使用)")
    @GetMapping("/selectByIdApp/{examineFlowId}")
    public  Result<ServeExamineFlowDetailVO> selectByIdApp(@PathVariable Long examineFlowId) {
        log.info("查询巡检记录详情(未巡检时小程序端使用)：{}",examineFlowId);
        ServeExamineFlowDetailVO serveExamineFlowDetailVO = serveExamineFlowService.selectByIdApp(examineFlowId);
        return Result.success(serveExamineFlowDetailVO);
    }

    //提交巡检记录(小程序)
    @ApiOperation("提交巡检记录(小程序)")
    @PostMapping("/add")
    public Result add(@RequestBody ServeFlowPlanAppDTO serveFlowPlanAppDTO) {
        log.info("提交巡检记录(小程序)：{}",serveFlowPlanAppDTO);
        serveExamineFlowService.add(serveFlowPlanAppDTO);
        return Result.success();
    }

}
